<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>设置配送关系(中心端)</title>
 <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>设置配送关系</h1>
        <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">目录管理</a></li>
            <li class="active"><a href="#">配送关系管理</a></li>
            <li class="active"><a href="#">设置配送关系</a></li>
        </ol>
    </section>
    <section class="content">
      <form id="form" method="post" class="form-horizontal">   
        <div class=" box box-success">
            <div class="box-body">
                <div class="input">
                       <div class="textalign1">所属项目：</div>
                       <div class="boxinput">
                          <select class="textinput" id="projId" name="projId" ></select>
                       </div>
                       <div class="textalign">商品编码：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput" id="goodsCode" name="goodsCode" placeholder="商品编码"/>
                       </div>
                       <div class="textalign">药品编码：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput" id="drugCode" name="drugCode" placeholder="药品编码"/>
                       </div>
                </div>
                <div class="input">
                       <div class="textalign1">通用名：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput" id="drugName" name="drugName" placeholder="通用名"/>
                       </div>
                       <div class="textalign">生产企业：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput" id="compName" name="compName" placeholder="生产企业" />
                       </div>
                       <div class="textalign">
                          <button type="button" onclick="gridSerch();" class="btn btn-success btn-sm">查&nbsp;询</button>
                       </div>
                </div>
		   </div>
	   </div>
	 </form>

	<table class="jqgrid" id="list4"></table>
     <div style="margin-top: 10px;"></div>
    <div id="prowed2"></div> 
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
$(document).ready(function (){
	jQuery("#list4").jqGrid({
		url: "${ctx}/baseDel/getDelDrugDataList.html",
	    mtype: "POST",
		datatype: "json",
		autowidth: true,
		shrinkToFit: false,
		height: 270,
	   	colNames:['操作','','所属项目','商品编码','药品编码','通用名','剂型','规格','转换系数','单位','材质','生产企业'],
	   	colModel:[
            {name:'oper',index:'n19',width:80, align:"center",sortable:false,
	             	formatter : function(val, opts, rowdata) {
    	            return "<a href='${ctx}/baseDel/toDelByHospList.html?goodsCode="+rowdata.goods_code+"&projID="+rowdata.proj_id+"' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -140px -60px' class='opIcon' title='按医疗机构设置配送企业'></a><a href='${ctx}/baseDel/toSetDelByComp.html?goodsCode="+rowdata.goods_code+"&projID="+rowdata.proj_id+"' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -120px -60px' class='opIcon' title='按企业设置医疗机构'></a>";
                    }	
	        },
	   		{name:'proj_id',index:'proj_id',hidden:true,width:100,align:"center", sorttype:false,sortable:false},
	   		{name:'proj_name',index:'proj_name',width:160, align:"left",sorttype:false,sortable:false},
			{name:'goods_code',index:'goods_code',key:true,width:100,align:"center", sorttype:false,sortable:false},
	   		{name:'drug_code',index:'drug_code',width:100,align:"center", sorttype:false,sortable:false},
	   		{name:'qualityspec_name',index:'qualityspec_name',width:140,align:"left",sortable:false,
				 formatter:function(val, opts, row) {
					  return "<a href=\"javascript:void(0);\" onclick=\"showDrugInfo('"+row.drug_code+"', '"+val+"')\">"+val+"</a>"
					 }},
	   		{name:'form_name',index:'form_name',width:80, align:"center",sorttype:false,sortable:false},
	   		{name:'spec_name',index:'spec_name',width:80, align:"left",sorttype:false,sortable:false},
	   		{name:'factor',index:'factor',width:80,align:"center", sorttype:false,sortable:false},
	   		{name:'unit_name',index:'unit_name',width:40,align:"center", sorttype:false,sortable:false},
	   		{name:'material_name',index:'material_name',width:80,align:"center", sorttype:false,sortable:false},
	   		{name:'prod_compname',index:'prod_compname',width:180,align:"left", sorttype:false,sortable:false,
	   			formatter:function(val, opts,row) {
	   			 return "<a href=\"javascript:void(0);\" onclick=\"showCompInfo('"+row.prod_compcode+"', '"+ val +"')\">"+val+"</a>"
	   			}
	   		}
	   		
	   	],
		gridComplete: function(){
			var ids = jQuery("#list4").jqGrid('getDataIDs');
			for(var i=0;i < ids.length;i++){
				var cl = ids[i];
				if (i % 2 == 0) {
				    ae = "&nbsp;&nbsp;<a href='javascript:hosDel("+cl+");' >禁用</a>&nbsp;&nbsp;";
				} else {
					ae = "&nbsp;&nbsp;<a href='javascript:hosDel("+cl+");' >启用</a>&nbsp;&nbsp;";
				}
				jQuery("#list4").jqGrid('setRowData',ids[i],{act:ae});
			}	
		},
		 rowNum: 20,
	     rowList: [10, 20, 50,100],
	     rownumbers: true,
	     pager: "#prowed2",
	     viewrecords: true,
	     caption: "设置配送关系",
	     editurl:"proPlanItemListHis.jsp",
	     jsonReader: {
	         repeatitems: false,
	         id: "ids"
	     }
	   	
	});
	$("#projId").HNSelect({
        url: "${pageContext.request.contextPath}/selectController/getProj.html", data: { ID: '' },defaultselect:'${form.patternType}',  defaultText: "<option value=''>请选择</option>",
    });
})

function gridSerch(){
	var goodsCode = $.trim($("#goodsCode").val());
	var drugCode = $.trim($("#drugCode").val());
	var drugName = $.trim($("#drugName").val());
	var projId = $.trim($("#projId").val());
	var compName = $.trim($("#compName").val());
	$("#list4").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{"goodsCode":goodsCode,
        		"drugCode":drugCode,
        		"drugName":drugName,
        		"projId":projId,
        		"compName":compName
        }
    }).trigger("reloadGrid"); //重新载入  
}

	    
</script>
</body>
</html>